// xc/components/form/switch.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    autochang:{
      type:Boolean,
      value:true,
    },
    value: {
      type: null,
      value: true
    },
    activetxt:
    {
      type: null,
      value: "是"
    },
    inactivetxt:
    {
      type: null,
      value: "否"
    },
    vtype: {
      type: "String",
      value: "xctype"
    },
    loading: Boolean,
    disabled: Boolean,
    activeColor: String,
    inactiveColor: String,
    activefontColor: String,
    inactivefontColor: String,
    size: {
      type: String,
      value: '30px',
    },
    activeValue: {
      type: null,
      value: true,
    },
    inactiveValue: {
      type: null,
      value: false,
    },
  },

  /**
   * 组件的初始数据
   */
  data: {

  },
  /**
   * 组件的方法列表
   */

  ready() {
    var app = getApp();
    try {
     
      if (!this.data.activeColor) {
        var prothem = app.globalData.configdata.prothem.themcolor.config
        var updatemodel = { activeColor: prothem.primarycolor, activefontColor: prothem.pribtncolor, inactiveColor: "#FAFAFA", inactivefontColor: 'rgba(153, 153, 153, 1)' }
        this.setData(updatemodel);
      }

    }
    catch (ex) {
      console.log("catch")

    }

  },
  methods: {
    onChange(ev) {
      
      if(this.data.autochang)
      {
        this.setData({value:ev.detail})
      }
   
      this.triggerEvent('change', ev.detail);
    }
  }
})
